package FileTree_Composite_09;

import java.util.List;

public class Directory extends FileSystemNode{
    private String name;
    private List<FileSystemNode> children;

    public Directory(String name) {
        this.name = name;
    }

    @Override
    public String getName() {
        return name;
    }

    public void addChild(FileSystemNode child) {
        if (children == null) {
            children = new java.util.ArrayList<>();
        }
        children.add(child);
    }

    @Override
    public void display(String indent) {
        System.out.println(indent + "Directory: " + getName() + "/");
        for (FileSystemNode child : children) {
            child.display(indent + "  ");
        }
    }
}
